package com.kaochong.xcx.utils;

import java.util.HashSet;
import java.util.Set;

/**
 * 去重处理工具类
 *
 * @author han
 * @date 2018-08-03 16:31
 */
public class DistinctUtil {
	
	private static final String match = "\\(|\\)|（|）|;|；|,|，|…|……|的|得|地|一|二|三|四|五|六|七|八|九|十|个|百|千|万|亿|年|月|日|周|天|几|两";
	
	public static boolean distinct(Set<String> zhSet, String str) {
		// 获取去除词性后的中文释义，并去除左右空格
		String zh = str.substring(str.indexOf(".") + 1).trim();
		if (zh.contains("(")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("（")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains(")")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("）")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains(";")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains(",")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("，")){
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("；")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("……")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("…")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("地")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("得")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("一")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("二")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("三")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("四")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("五")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("六")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("七")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("八")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("九")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("十")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("个")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("百")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("千")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("万")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("亿")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("天")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("年")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("月")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("日")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("周")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("几")) {
			zh = zh.replaceAll(match, "");
		}
		if (zh.contains("两")) {
			zh = zh.replaceAll(match, "");
		}
		
		char[] chars = zh.toCharArray();
		
		for (String s : zhSet) {
			for (char aChar : chars) {
				String s1 = String.valueOf(aChar);
				if (s.contains(s1)) {
					return true;
				}
			}
		}
		return false;
	}
	
	public static void main(String[] args) {
		Set<String> zhSet = new HashSet<>();
		zhSet.add("adj. 佛教的");
		zhSet.add("adj. 国外的");
		zhSet.add("adj. (突然的)，莽撞的");
		
		String str = "adj. (明)确的";
		boolean distinct = distinct(zhSet, str);
		System.out.println(distinct);
	}
}
